<!--论文隐匿名评审审批 导师审批-->
<template>
    <div class="con">
        <inner-breadcrumb v-model="pathKey" :path="path"></inner-breadcrumb>
        <div v-show="pathKey==='main'">
            <ConditionCard shadow="never" body-style="padding: 24px 24px 6px 24px;" @search="onSubmit" @reset="reset('queryForm')">
                <el-form ref="queryForm" label-suffix="：" :model="queryForm" label-position="right" label-width="120px">
                    <el-row :gutter="24">
                        <el-col :span="8">
                            <el-form-item :label="$t('label.schoolTerm')">
                                <CalendarSelect v-model="queryForm.yearTerm" @load-done="loadDone"></CalendarSelect>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('label.grade')">
                              <el-date-picker v-model="queryForm.grade" :clearable="true" value-format="yyyy" type="year" :placeholder="$t('paperBlindTrial.gredeTips')" style="width: 100%" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('label.college')">
                              <el-select
                                v-model="queryForm.academyCode"
                                style="width: 100%;"
                                clearable
                                filterable
                                :placeholder="$t('common.text.all')"
                                v-clearreadonly
                              >
                                <el-option
                                    v-for="item in options.academyCode"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                              </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="24">
                        <el-col :span="8">
                            <el-form-item :label="$t('label.major')">
                                <MyMajor :faculty="queryForm.academyCode" :filterable="true" :grade="queryForm.grade" v-model="queryForm.majorCode" :clearable="true" v-clearreadonly> </MyMajor>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('label.trainingLevel')">
                                <DictSelect v-model="queryForm.eduLevel" :data="options.eduLevel" :clearable="true"></DictSelect>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('label.trainingCategory')">
                                <DictSelect v-model="queryForm.eduMode" :filterable="true" :data="options.eduMode" :clearable="true" ></DictSelect>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="24">
                        <el-col :span="8">
                            <el-form-item :label="$t('label.degreeCategory')">
                                <DictSelect v-model="queryForm.degreeType" :data="options.degreeType" :clearable="true"></DictSelect>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('label.formLearning')">
                                <DictSelect v-model="queryForm.studyForm" :data="options.studyForm" :clearable="true"></DictSelect>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('paperBlindTrial.isDraw')">
                                <DictSelect v-model="queryForm.selectedFlag" :data="options.selectedFlag" :clearable="true"></DictSelect>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="24">
                        <el-col :span="8">
                            <el-form-item :label="$t('paperBlindTrial.evaStatus')">
                              <DictSelect v-model="queryForm.evaStatus" :data="options.evaStatus" :clearable="true"></DictSelect>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('paperBlindTrial.batchName')">
                              <el-input v-model="queryForm.batchNo" :placeholder="$t('common.pla.pleaseInput')"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('achievementApply.thesisTitle')">
                              <el-input v-model="queryForm.thesisTitle" :placeholder="$t('common.pla.pleaseInput')" :clearable="true"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="24">
                        <el-col :span="8">
                          <el-form-item :label="$t('courseSummary.aduitType')">
                              <DictSelect
                                  v-model="queryForm.status"
                                  :data="options.applyStatus"
                                  :clearable="true"
                              ></DictSelect>
                          </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </ConditionCard>
            <el-card shadow="never" body-style="padding: 24px;">
              <h1 class="condition-title">{{$t('paperBlindTrial.reviewApprovalTitle')}}</h1>
              <div class="edu-opertion-bar">
                <div class="float-left">
                  <KeywordInput v-model="queryForm.keyword" :placeholder="$t('achievementApply.tableIplaceholder')" @enter="search"></KeywordInput>
                </div>
              </div>
              <edu-table ref="tables" :url="tableApi" :selection="false" :orderFixed="true">
                  <el-table-column :min-width="90" :label="$t('label.stuCode')" prop='stuNo' show-overflow-tooltip fixed="left">
                  </el-table-column>
                  <el-table-column :min-width="70" :label="$t('label.stuName')" prop='stuName' show-overflow-tooltip fixed="left">
                  </el-table-column>
                  <el-table-column :min-width="item.width" v-for="item in label" :key="item.props" :label="item.label" :prop="item.props" show-overflow-tooltip></el-table-column>
                  <el-table-column :min-width="120" :label="$t('paperBlindTrial.preDefenseFlag')" show-overflow-tooltip
                  :formatter="(row) => { return fieldChange(options.preDefenseFlag, row.preDefenseFlag); }">
                  </el-table-column>
                  <el-table-column :min-width="100" :label="$t('courseSummary.aduitType')" show-overflow-tooltip>
                    <template slot-scope="scope">
                      <el-tag
                        v-if="getType(scope.row.status)"
                        :type="getType(scope.row.status)"
                      >{{ fieldChange(options.applyStatus, scope.row.status) }}</el-tag>
                    </template>
                  </el-table-column>
                  <el-table-column :min-width="80" :label="$t('paperBlindTrial.evaStatus')" show-overflow-tooltip
                  :formatter="(row) => { return fieldChange(options.evaStatus, row.evaStatus); }" fixed="right">
                  </el-table-column>
                  <el-table-column :min-width="80" :label="$t('paperBlindTrial.isDraw')" show-overflow-tooltip
                  :formatter="(row) => { return fieldChange(options.selectedFlag, row.selectedFlag); }" fixed="right">
                  </el-table-column>
                  <el-table-column width="80px" :label="$t('nonPublicCourseOpen.operation')" fixed="right">
                      <template slot-scope="scope">
                          <div class="con_btns">
                            <el-button type="text" @click="audit('view', scope.row)">{{$t('message.Look')}}</el-button>
                            <el-button type="text" v-if="scope.row.status === 'TUTOR_SUBMIT'" @click="audit('audit', scope.row)">{{$t('common.btn.approve')}}</el-button>
                          </div>
                      </template>
                  </el-table-column>
              </edu-table>
            </el-card>
        </div>
        <!-- 申请审批 -->
        <paperAudit v-if="pathKey==='paperAudit'" :editForm="true" :auditType="auditType" :row="objs" @emit:back="backFunc"></paperAudit>
    </div>
</template>

<script>
import { tutorAuditTableList } from "common/src/api/paperBlindTrial";
import MyMajor from "common/src/views/administrator/undergraduateTutor/component/MyMajor";
import paperAudit from './paperAudit';
import commonMixins from 'common/src/views/practiceManagement/commonMixins';
import { queryDic } from 'common/src/api/dictionary';
export default {
    components: {
        MyMajor,
        paperAudit
    },
    mixins: [commonMixins],
    props: {},
    data() {
        return {
            tableApi: tutorAuditTableList,
            dialogFlag: false,
            objs: {},
            yearTerms: '',
            queryForm: {
              keyword: '',
              yearTerm: '', // 学年学期
              grade: '', // 年级
              academyCode: '', // 学院
              majorCode: '', // 专业
              eduLevel: '', // 培养层次
              eduMode: '', // 培养类别
              degreeType: '', // 学位类别
              studyForm: '', // 学习形式
              selectedFlag: '', // 是否抽中
              evaStatus: '', // 是否送审
              batchNo: '', // 批次
              thesisTitle: '', // 论文题目
              status: 'TUTOR_SUBMIT'
            },
            label: [
                { label: this.$t('label.schoolTerm'), props: 'yearTermI18n', width: 180 },
                // { label: this.$t('label.stuCode'), props: 'stuNo', width: 100 },
                // { label: this.$t('label.stuName'), props: 'stuName', width: 100 },
                { label: this.$t('label.grade'), props: 'grade', width: 80 },
                { label: this.$t('label.college'), props: 'academyName', width: 150 },
                { label: this.$t('label.major'), props: 'majorName', width: 150 },
                { label: this.$t('label.trainingLevel'), props: 'eduLevelI18n', width: 80 },
                { label: this.$t('label.trainingCategory'), props: 'eduModeI18n', width: 100 },
                { label: this.$t('label.degreeCategory'), props: 'degreeTypeI18n', width: 80 },
                { label: this.$t('label.formLearning'), props: 'studyFormI18n', width: 80 },
                { label: this.$t('achievementApply.thesisTitle'), props: 'thesisTitle', width: 100 },
                { label: this.$t('paperBlindTrial.batchName'), props: 'batchNo', width: 90 },
            ],
            options: {
              academyCode: [], // 学院
              applyStatus: [
                { label: this.$t('paperBlindTrial.tutorSubmit'), value: 'TUTOR_SUBMIT', type: 'warning' },
                { label: this.$t('paperBlindTrial.blindSubmit'), value: 'BLIND_SUBMIT', type: 'warning' },
                { label: this.$t('paperBlindTrial.tutorPass'), value: 'TUTOR_PASS', type: 'success' },
                { label: this.$t('paperBlindTrial.agreeLabel'), value: 'PASS', type: 'success' },
                { label: this.$t('achievementApply.refuse'), value: 'REJECT', type: 'danger' },
              ],
              eduLevel: [], // 培养层次
              eduMode: [], // 培养类别
              degreeType: [], // 学位类型
              studyForm: [], // 学习形式
              majorCode: [],
              preDefenseFlag: [
                { label: this.$t('message.yes'), value: 'Y', type: 'success' },
                { label: this.$t('message.no'), value: 'N', type: 'danger' }
              ],
              selectedFlag: [
                { label: this.$t('paperBlindTrial.notDrawn'), value: 'UNBLIND', type: '' }, // 未抽盲
                { label: this.$t('paperBlindTrial.drawn'), value: 'Y', type: 'success' }, // 抽中
                { label: this.$t('paperBlindTrial.missed'), value: 'N', type: 'warning' } // 未中
              ],
              evaStatus: [
                { label: this.$t('paperBlindTrial.hasSend'), value: 'Y', type: 'success' },
                { label: this.$t('paperBlindTrial.notSend'), value: 'N', type: 'warning' }
              ],
            },
            pathKey: 'main',
            path: {
              label: this.$t('paperBlindTrial.approvalLable'),
              key: 'main',
              disable: false,
              children: [
                { label: this.$t('message.detail'), key: 'paperAudit', disable: true, }
              ]
            },
            auditType: ''
        };
    },
    computed: {

    },
    created() {

    },
    mounted() {
        let param = {
          X_YX: 'academyCode', // 学院
          // X_PYCC: 'eduLevel', // 培养层次
          X_PYLB: 'eduMode', // 培养类别
          X_XWLX: 'degreeType', // 学位类型
          K_XXXS: 'studyForm', // 学习形式
          G_ZY: 'majorCode' // 专业:
        };
        this.initOptions(param);
        this.onSubmit();
        this.getEdulevel();
    },
    methods: {
        getEdulevel() { // val: {  X_PYCC: 'trainingLevel',   G_ZY: 'profession'} // 专业
          const data = {
            lang: this.$store.getters.language || 'cn',
            type: 'allChild',
            keys: ['X_PYCC']
          };
          return new Promise((resolve, reject) => {
              queryDic(data).then(res => {
                  if (res.code === 200) {
                    this._fill('eduLevel', res.data['X_PYCC']);
                    this.options.eduLevel = this.options.eduLevel.filter(v => v.value === '4' || v.value === '6');
                  }
                  resolve(this.options);
              }).catch((err) => {
                  reject(err);
              });
          });
        },
        onSubmit() { // 筛选
          this.$refs.tables.pageNum = 1;
          this.$refs.tables.search(this.queryForm);
        },
        search() {
          this.queryForm.keyword = this.queryForm.keyword.trim();
          this.onSubmit();
        },
        audit(type, row) { // 审批
          this.pathKey = 'paperAudit';
          this.objs = row;
          this.auditType = type;
        },
        reset() {  // 重置
          for (const key in this.queryForm) {
            if (key !== 'yearTerm' ) {
              this.queryForm[key] = '';
            }
          }
          this.queryForm.status = 'TUTOR_SUBMIT';
          this.queryForm.yearTerm = this.yearTerms;
          this.onSubmit();
        },
        loadDone() { // 页面加载时保存学期学年
          this.yearTerms = this.queryForm.yearTerm;
        },
        // 审批完成返回方法
        backFunc () {
          this.pathKey = 'main';
          this.onSubmit();
        },
        getType(val) {
          let option = this.options.applyStatus.find(v => v.value == val)
          return option ? option.type : null
        },
    }
};
</script>

<style scoped lang="scss">
</style>

